<?php

namespace app\commands;

use Yii;
use app\models\User;
use app\models\RegionType;
use app\models\Region;
use app\models\Weather;
use app\models\Forecast;
use yii\console\Controller;

class HelloController extends Controller
{
    public function actionInit()
    {
        $user = new User();
        $user->firstName = 'Иван';
        $user->lastName = 'Иванов';
        $user->email = 'ivanovtest@mail.ru';
        $user->password = \Yii::$app->security->generatePasswordHash('1123424');

        if( !$user->save() ) {
          echo "Error: ". $user->errors; 
        }

        echo "User add successfull.\n";

        $regType = new RegionType();
        $regType->type = 'Тест';

        if( !$regType->save() ) {
          echo "Error: ". $regType->errors; 
        }

        echo "Region type add successfull.\n";
    }
}
